package com.yihaodian.search;

import org.apache.lucene.search.Filter;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TopDocsCollector;

import com.yihaodian.api.search.SearchRequest;
import com.yihaodian.api.search.SearchResponse;
import com.yihaodian.cluster.Node;
import com.yihaodian.index.meta.shard.Shard;
import com.yihaodian.search.broker.shard.ShardSearchRequest;
import com.yihaodian.search.core.Searcher;
import com.yihaodian.search.fetch.FetchRequest;
import com.yihaodian.search.fetch.FetchSearchResult;
import com.yihaodian.search.query.QuerySearchResult;

/**
 * 
 * search request context
 *
 */
public class SearchContext {
	private long id;
	
	private Shard shard;
	
	private Node node;
	
	private ShardSearchRequest shardRequest;
	
	private FetchRequest fetchRequest;
	
	private int[] docIdsToLoad;
	
	private Searcher searcher;
	
	private Query query;
	
	private QuerySearchResult queryResult;
	
	private FetchSearchResult fetchResult;
	
	private SearchResponse response;
	
	private TopDocsCollector collector;
	
	private Filter filter;
	
	private Sort sort;
	
	public SearchContext(long id, Shard shard, 
			ShardSearchRequest shardRequest, Searcher searcher) {
		this.id = id;
		this.shard = shard;
		this.shardRequest = shardRequest;
		this.searcher = searcher;
	}
	
	public SearchContext(ShardSearchRequest shardRequest, SearchResponse response,
			Searcher searcher) {
		this.shardRequest = shardRequest;
		this.response = response;
		this.searcher = searcher;
	}
	
	public SearchContext() {
		
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public ShardSearchRequest getShardRequest() {
		return shardRequest;
	}
	
	public SearchRequest getRequest(){
		return shardRequest.getSearchRequest();
	}

	public void setShardRequest(ShardSearchRequest shardRequest) {
		this.shardRequest = shardRequest;
	}

	public Searcher getSearcher() {
		return searcher;
	}

	public void setSearcher(Searcher searcher) {
		this.searcher = searcher;
	}

	public Query getQuery() {
		return query;
	}

	public void setQuery(Query query) {
		this.query = query;
	}

	public QuerySearchResult getQueryResult() {
		return queryResult;
	}

	public void setQueryResult(QuerySearchResult queryResult) {
		this.queryResult = queryResult;
	}

	public FetchSearchResult getFetchResult() {
		return fetchResult;
	}

	public void setFetchResult(FetchSearchResult fetchResult) {
		this.fetchResult = fetchResult;
	}

	public Shard getShard() {
		return shard;
	}

	public void setShard(Shard shard) {
		this.shard = shard;
	}

	public SearchResponse getResponse() {
		return response;
	}

	public void setResponse(SearchResponse response) {
		this.response = response;
	}

	public int[] getDocIdsToLoad() {
		return docIdsToLoad;
	}

	public void setDocIdsToLoad(int[] docIdsToLoad) {
		this.docIdsToLoad = docIdsToLoad;
	}

	public FetchRequest getFetchRequest() {
		return fetchRequest;
	}

	public void setFetchRequest(FetchRequest fetchRequest) {
		this.fetchRequest = fetchRequest;
	}

	public TopDocsCollector getCollector() {
		return collector;
	}

	public void setCollector(TopDocsCollector collector) {
		this.collector = collector;
	}

	public Filter getFilter() {
		return filter;
	}

	public void setFilter(Filter filter) {
		this.filter = filter;
	}

	public Sort getSort() {
		return sort;
	}

	public void setSort(Sort sort) {
		this.sort = sort;
	}

	public Node getNode() {
		return node;
	}

	public void setNode(Node node) {
		this.node = node;
	}

}
